package ch.headshot.photomap.client.editor.control;

import java.util.List;

import ch.headshot.photomap.client.editor.view.GpxStructure;
import ch.headshot.photomap.client.gpx.Track;
import ch.headshot.photomap.client.gpx.TrackSegment;
import ch.headshot.photomap.client.gpx.WayPoint;

import com.google.gwt.user.client.Command;

public class SimplifyCommand implements Command {

	public void execute() {
		for (Track track : GpxStructure.getInstance().getSelectedTracks()) {
			for (TrackSegment segments : track.getSegments()) {
				List<WayPoint> simplified = new Simplifier().simplify(segments.getPoints());
				segments.getPoints().clear();
				segments.getPoints().addAll(simplified);
			}
		}
		GpxStructure.getInstance().refresh();
	}

}
